package com.czumi.javawx;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.czumi.javawx.constants.UrlConst;
import com.czumi.javawx.interceptor.LoginInterceptor;

@SpringBootApplication
//开启缓存  
@EnableCaching 
public class JavawxApplication extends WebMvcConfigurerAdapter {

	

	public static void main(String[] args) {
		SpringApplication.run(JavawxApplication.class, args);
	}
	
	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		// TODO Auto-generated method stub
		registry.addRedirectViewController("/", UrlConst.URL_ADMIN_INDEX);
		// registry.addViewController("/").setViewName("index");
	}
	
	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截规则：除了login，其他都拦截判断
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/admin/**");
        super.addInterceptors(registry);
    }

}
